<!DOCTYPE html "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">


<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm">
                        <input type="hidden" name="id" th:value="${sysConfig.id}">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">参数名称：</label>
                            <div class="col-sm-8">
                                <input id="paramDesc" name="paramDesc" th:value="${sysConfig.paramDesc}"
                                       class="form-control" type="text" readonly="readonly" style="width: 300px;">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">参数Key：</label>
                            <div class="col-sm-8">
                                <input id="paramKey" name="paramKey" th:value="${sysConfig.paramKey}"
                                       class="form-control" type="text" readonly="readonly" style="width: 300px;">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">参数值：</label>
                            <div class="col-sm-8">
                                <input id="paramValue" name="paramValue" th:value="${sysConfig.paramValue}"
                                       class="form-control" type="text" style="width: 300px;">
                            </div>
                        </div>

                        <div class="text-right form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button type="submit" class="btn btn-primary">保存</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    $().ready(function () {
        validateRule();
    });

    $.validator.setDefaults({
        submitHandler: function () {
            save();
        }
    });


    function save() {
        $.ajax({
            cache: true,
            type: "POST",
            url: "/mp/sysParam/update",
            data: $('#signupForm').serialize(), // 你的formid
            async: false,
            error: function (request) {
                parent.layer.alert("操作失败");
            },
            success: function (data) {
                if (data.code == 0) {
                    parent.layer.msg("操作成功");
                    parent.reLoad();
                    var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                    parent.layer.close(index);
                } else {
                    parent.layer.alert(data.msg)
                }

            }
        });
    }

    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#signupForm").validate({
            rules: {
                paramValue: {
                    required: true
                }
            },
            messages: {
                paramValue: {
                    required: icon + "必填"
                }
            }
        })
    }

</script>
</body>
</html>